#ifndef GOOLNN_CANGYAN_WINDOW_EDITOR
#define GOOLNN_CANGYAN_WINDOW_EDITOR

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTextEdit>
#include <QSplitter>
#include <QToolBar>
#include <QWidget>
#include <QLabel>

#include "window/NotesViewer.hpp"
#include "window/ImageViewer.hpp"

class Editor : public QWidget{
    Q_OBJECT
    
    private:
        CYFile* file;
        
        QVBoxLayout* layout;

        QSplitter* splitter;

        ImageViewer* imageViewer;

        QWidget* textWidget;
        QVBoxLayout* textLayout;
        QLabel* indexLabel;
        // NotesViewer* notesViewer;

        QToolBar* toolBar;
        QAction* normalAction;
        QAction* markAction;
        QAction* noteAction;

        QSplitter* textEditSplitter;
        // 初译输入框
        QTextEdit* initialTextEdit;
        // 校对输入框
        QTextEdit* proofreadingTextEdit;
        // 文本输入框
        // QTextEdit* textEdit;

        QHBoxLayout* buttonLayout;
        QPushButton* addButton;
        QPushButton* removeButton;

        QHBoxLayout* buttomLayout;
        QPushButton* previousButton;
        QLabel* pageLabel;
        QPushButton* nextButton;

        bool addingNote;
    
    public:
        Editor(CYFile* file);

        ~Editor();

        QString getFileName();
        QString getFilePath();

        CYFile* getFile();
        
        ImageViewer* getImageViewer();

        void saveFile();

        bool isSaved();

        bool isAddingNote();

        void reload();
    
    private slots:
        void updatePage();
        void updateText();
        void updateDelete();

        void saveInitialText();
        void saveProofreadingText();

        // void add();
        void addDone();

        // void remove();

        void mergeNormal();
        void mergeMark();
        void mergeNote();
    
    public slots:
        void previousPage();
        void nextPage();
        void addNote();
        void removeNote();
    
    signals:
        void pageChanged();
        void focusChanged();
        void adding();
        void added();

};

#endif
